import dayjs from "dayjs";
import { isHoliday } from "chinese-days";

export const getAllTradeDaysOfYear = (year) => {
	const startDay = dayjs(`${year}-01-01`);
	const endDay = dayjs(`${year}-12-31`);

	// 获取指定年份的所有日期
	const betweendays = endDay.diff(startDay, "day") + 1;

	return Array.from({ length: betweendays }, (_, i) =>
		startDay.add(i, "day").format("YYYY-MM-DD")
	)
		.filter((day) => !isHoliday(day))
		.filter((day) => ![6, 0].includes(dayjs(day).day()));
};
